﻿using Digitalmes.Domain.Entities.Mes.Masters;

namespace Digitalmes.Application.Mes.Masters.Workstations.Queries;

/// <summary>
/// 工位查询命令。
/// </summary>
public record GetWorkstationListQuery(long LineId) : IRequest<IResult<List<MdWorkstationDto>>>;

internal sealed class GetWorkstationListQueryHandler(IRepository<MdWorkstation> repo) : IRequestHandler<GetWorkstationListQuery, IResult<List<MdWorkstationDto>>>
{
    public async Task<IResult<List<MdWorkstationDto>>> Handle(GetWorkstationListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(m => m.LineId == request.LineId, m => m.Order, false, cancellationToken);
        return Result.From(items.Adapt<List<MdWorkstationDto>>());
    }
}
